package com.bluesky.jwf.component;

import com.bluesky.javawebbrowser.domain.html.tags.A;
import com.bluesky.jwf.component.event.EventHandler;

/**
 * TODO it is not finished
 * 
 * @author hz00260
 * 
 */
public class HyperLinkButton extends Component {
	public static String EVENT_CLICK = "click";

	private A hyperLinkTag;

	@Override
	public void init(String html) {
		super.init(html);
		eventHandlers.put(EVENT_CLICK, null);

		hyperLinkTag = (A) loadByJwfClass("link");

	}

	public String getText() {
		return hyperLinkTag.getBody();
	}

	public void setText(String text) {
		hyperLinkTag.setText(text);
	}

	public void setClickHandler(EventHandler handler) {
		eventHandlers.put(EVENT_CLICK, handler);

		if (handler != null) {
			hyperLinkTag.setOnClick(String.format("_oum_post2('%s','click')",
					getId()));
		} else
			hyperLinkTag.setOnClick("");
	}

	public void setDisable(boolean v) {
		if (v) {
			hyperLinkTag.setOnClick("return false;");
		} else
			hyperLinkTag.setOnClick(String.format("_oum_post2('%s','click')",
					getId()));

	}
}
